const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');

module.exports = {
    /* 基础配置 */
    mode: 'production',
    entry: './src/index.js',
    output: {
        filename: '[name].[hash:8].js',
        path: path.resolve(__dirname, './dist')
    },
    /* 使用插件 */
    plugins: [
        new HtmlWebpackPlugin({
            template: './public/index.html',
            filename: 'index.html',
            minify: true
        }),
        new CleanWebpackPlugin()
    ],
    /* DEV-SERVER */
    devServer: {
        host: '127.0.0.1', //域名
        port: 3000, //端口号
        open: true, //自动打开浏览器
        hot: true, //热更新
        compress: true //开启服务器端的GZIP压缩
    }
};